package top.codechap.transaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Random;
import java.util.UUID;

/**
 * @author CodeChap
 * @date 2021-06-23 22:04
 * @description UserDao
 */
@Repository
public class UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void insert() {
        String sql = "insert into `user` (username,age) VALUES (?,?)";
        String username = UUID.randomUUID().toString().substring(0,5);
        int age = (int)(Math.random() * 100);
        jdbcTemplate.update(sql,username,age);
    }
}
